package raytracer.misc;

import raytracer.math.Vector3d;

/**
 * 
 * @author Thorsten Roth
 * @version 07.06.2006
 */
public class Ray {

	private Vector3d position;
	private Vector3d direction;
	private float refrIndex;
	private static long currentRayID;
	private long rayID;
		
	static {
		currentRayID=Long.MIN_VALUE+1;
	}
	
	public Ray(Ray ray) {
		rayID=currentRayID++;
		this.position=new Vector3d(ray.getOrigin());
		this.direction=new Vector3d(ray.getDirection());
		this.direction.normalize();
		this.refrIndex=ray.getRefrIndex();
	}
	
	public Ray(Vector3d pos, Vector3d dir) {
		rayID=currentRayID++;
		this.position=pos;
		this.direction=dir;
		this.direction.normalize();
		this.refrIndex=1;
	}
	
	public void setPosition(Vector3d pos) {
		this.position=pos;
	}
	
	public void setDirection(Vector3d dir) {
		this.direction=dir;
		this.direction.normalize();
	}
	
	public void setRefrIndex(float refrIndex) {
		this.refrIndex=refrIndex;
	}
	
	public Vector3d getOrigin() {
		return this.position;
	}
	
	public Vector3d getDirection() {
		return this.direction;
	}
	
	public float getRefrIndex() {
		return this.refrIndex;
	}
	
	public long getRayID() {
		return this.rayID;
	}
	
	public String toString() {
		return 
			 "Pos: "+this.getOrigin()+"\n"
			+"Dir: "+this.getDirection()+"\n"
			+"Ref: "+this.getRefrIndex();
	}
	
}
